/*
 * Copyright (c) 2008-2021 浩瀚深度 All Rights Reserved.
 *
 * <p>FileName: ServerManageController.java</p>
 *
 * @author zz
 * @date 2024/3/11
 * @version 1.0
 * History:
 * v1.0.0 2024/3/11 Create
 */
package com.monitor.controller;

import com.monitor.base.Result;
import com.monitor.base.ResultCode;
import com.monitor.entity.ServerManageConfig;
import com.monitor.entity.Syslog;
import com.monitor.mapper.ServerManageMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>Title: ServerManageController</p>
 * <p>Description: </p>
 *
 * @author zz
 */
@Slf4j
@RestController
@RequestMapping("/server")
@CrossOrigin(origins = "*")
public class ServerManageController {


    @Autowired
    private ServerManageMapper serverManageMapper;

    @PostMapping("/list")
    public Result listSyslog() {
        List<ServerManageConfig> dataList = serverManageMapper.selectAll();
        return new Result(ResultCode.SUCCESS, dataList);
    }

    @PostMapping("/create")
    public Result create(@RequestBody ServerManageConfig server) {
        serverManageMapper.insert(server);
        return new Result(ResultCode.SUCCESS, "添加成功");
    }

    @PostMapping("/remove")
    public Result remove(@RequestBody ServerManageConfig server) {
        serverManageMapper.deleteById(server.getId());
        return new Result(ResultCode.SUCCESS, "删除成功");
    }
}
